package com.art.sunflower.mapper;

import com.art.sunflower.pojo.Teacher;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface TeacherMapper {

    @Select("select * from teacher_information_view")
    List<Map<String, Object>> selectList();

    @Insert("insert into teacher(user_id, email) values(#{id}, #{email})")
    void insertTeacher(Integer id, String email);

    @Update("update teacher set email = #{email} where id = #{id}")
    void updateEmail(Integer id, String email);

    @Select("select * from teacher where id = #{id}")
    Map<String, Object> selectTeacher(Integer id);

    @Delete("delete from teacher where id = #{id}")
    void delete(Integer id);

    @Select("select * from teacher_information_view where id = #{id}")
    Map<String, Object> selectById(Integer id);

    @Select("select * from teacher where id=#{id}")
    Teacher selectOneTeacherById(Integer id);

    @Select("select email from teacher where user_id = #{id}")
    String selectEmail(Integer id);

    @Select("select * from teacher_name_view")
    List<Map<String, Object>> selectName();

    @Update("update teacher set is_leave = #{status} where id = #{id}")
    void updateStatus(Integer id, Boolean status);

}
